/**
 */
package OBSL.impl;

import OBSL.OBSLPackage;
import OBSL.PresentIndividual;
import OBSL.SubParameter;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Sub Parameter</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.SubParameterImpl#getReferenceTo <em>Reference To</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SubParameterImpl extends ParameterImpl implements SubParameter {
	/**
	 * The cached value of the '{@link #getReferenceTo() <em>Reference To</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReferenceTo()
	 * @generated
	 * @ordered
	 */
	protected PresentIndividual referenceTo;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SubParameterImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.SUB_PARAMETER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresentIndividual getReferenceTo() {
		if (referenceTo != null && referenceTo.eIsProxy()) {
			InternalEObject oldReferenceTo = (InternalEObject)referenceTo;
			referenceTo = (PresentIndividual)eResolveProxy(oldReferenceTo);
			if (referenceTo != oldReferenceTo) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OBSLPackage.SUB_PARAMETER__REFERENCE_TO, oldReferenceTo, referenceTo));
			}
		}
		return referenceTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PresentIndividual basicGetReferenceTo() {
		return referenceTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetReferenceTo(PresentIndividual newReferenceTo, NotificationChain msgs) {
		PresentIndividual oldReferenceTo = referenceTo;
		referenceTo = newReferenceTo;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OBSLPackage.SUB_PARAMETER__REFERENCE_TO, oldReferenceTo, newReferenceTo);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReferenceTo(PresentIndividual newReferenceTo) {
		if (newReferenceTo != referenceTo) {
			NotificationChain msgs = null;
			if (referenceTo != null)
				msgs = ((InternalEObject)referenceTo).eInverseRemove(this, OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO, PresentIndividual.class, msgs);
			if (newReferenceTo != null)
				msgs = ((InternalEObject)newReferenceTo).eInverseAdd(this, OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO, PresentIndividual.class, msgs);
			msgs = basicSetReferenceTo(newReferenceTo, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.SUB_PARAMETER__REFERENCE_TO, newReferenceTo, newReferenceTo));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.SUB_PARAMETER__REFERENCE_TO:
				if (referenceTo != null)
					msgs = ((InternalEObject)referenceTo).eInverseRemove(this, OBSLPackage.PRESENT_INDIVIDUAL__ASSIGNED_TO, PresentIndividual.class, msgs);
				return basicSetReferenceTo((PresentIndividual)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.SUB_PARAMETER__REFERENCE_TO:
				return basicSetReferenceTo(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.SUB_PARAMETER__REFERENCE_TO:
				if (resolve) return getReferenceTo();
				return basicGetReferenceTo();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.SUB_PARAMETER__REFERENCE_TO:
				setReferenceTo((PresentIndividual)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.SUB_PARAMETER__REFERENCE_TO:
				setReferenceTo((PresentIndividual)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.SUB_PARAMETER__REFERENCE_TO:
				return referenceTo != null;
		}
		return super.eIsSet(featureID);
	}

} //SubParameterImpl
